import request from '@/request/request'

// 创建销售出库单
export function createSalesOutbound(outbound) {
    return request({
        method: "post",
        url: '/sales/outbound',
        data: outbound
    })
}

// 分页获取销售出库单
export function getSalesOutboundPage(pageParams) {
    return request({
        method: "post",
        url: '/sales/outbound/page',
        data: pageParams
    })
}

// 获取仓库列表
export function getWarehouse() {
    return request({
        method: "get",
        url: '/sales/warehouse',
    })
}

// 获取销售出库单详情（包含明细）
export function getSalesOutboundWithDetails(id) {
    return request({
        method: "get",
        url: `/sales/outbound/withDetails/${id}`,
    })
}

// 更新销售出库单
export function updateSalesOutbound(outbound) {
    return request({
        method: "put",
        url: '/sales/outbound',
        data: outbound
    })
}

// 删除销售出库单
export function deleteSalesOutbound(id) {
    return request({
        method: "delete",
        url: `/sales/outbound/${id}`,
    })
}

// 获取销售出库单列表（用于选择，排除已退货的出库单）
export function getSalesOutboundForReturn(pageParams) {
    return request({
        method: "post",
        url: '/sales/outbound/page',
        data: { ...pageParams, excludeReturn: true }
    })
}

// 根据出库单ID获取出库单详情（用于退货单创建）
export function getSalesOutboundById(id) {
    return request({
        method: "get",
        url: `/sales/outbound/withDetails/${id}`,
    })
}